package com.hyzx.qbasic.admin.domain.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hyzx.qbasic.admin.domain.dao.DbQueryMapper;
import com.hyzx.qbasic.admin.domain.repository.IDbQueryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Created by 黄江华 on 2017/10/31
 */

@Repository
public class DbQueryRepositoryImpl implements IDbQueryRepository {
    @Autowired
    DbQueryMapper dbQueryMapper;

    @Override
    public PageInfo<Map<String, Object>> query(int pageNum, int pageSize, String sql) {
        PageInfo pageInfo = PageHelper.startPage(pageNum, pageSize)
                .doSelectPageInfo(() -> dbQueryMapper.query(sql));

        return pageInfo;
    }
}
